<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1 , user-scalable=no">
<title>员工查询</title>
<link href="__PUBLIC__/plugins/bootstrap.css" rel="stylesheet">
<link href="__PUBLIC__/plugins/bootstrap-dashen.css" rel="stylesheet">
<link href="__PUBLIC__/plugins/font-awesome.css" rel="stylesheet">
<link href="__PUBLIC__/plugins/animate.css" rel="stylesheet">
<link href="__PUBLIC__/plugins/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
</head>
<body style="margin-top:70px;">
<div class="container">
{include file="common/header" /}
	<div class="col-md-9 wow fadeInLeft">
		<ul class="breadcrumb">
  			<li><a href="__PUBLIC__/index.php">首页</a></li>
  			<li><a href="{:url('Employee/frontlist')}">员工信息列表</a></li>
  			<li class="active">查询结果显示</li>
  			<a class="pull-right" href="{:url('Employee/frontAdd')}" style="display:none;">添加员工</a>
		</ul>
		<div class="row">
			<?php
				/*计算起始序号*/
				$startIndex = ($currentPage-1) * $rows;
				$currentIndex = $startIndex+1;
				/*遍历记录*/
			?>
			{volist name="employeeRs" id="employee" key="i"}
			<?php
				$clearLeft = "";
				if(($i-1)%4 == 0) $clearLeft = "style=\"clear:left;\"";
			?>
			<div class="col-md-3 bottom15" {$clearLeft}>
			  <a  href="{:url('Employee/frontshow',array('bianhao'=>$employee['bianhao']))}"><img class="img-responsive" src="__PUBLIC__/{$employee.zhaopian}" /></a>
			     <div class="showFields">
			     	<div class="field">
	            		员工编号:{$employee.bianhao}
			     	</div>
			     	<div class="field">
	            		姓名:{$employee.xingming}
			     	</div>
			     	<div class="field">
	            		性别:{$employee.xingbie}
			     	</div>
			     	<div class="field">
	            		部门:{$employee.bumenObjF.bumenmingcheng}
			     	</div>
			     	<div class="field">
	            		担任职务:{$employee.danrenzhiwu}
			     	</div>
			     	<div class="field">
	            		民族:{$employee.minzu}
			     	</div>
			     	<div class="field">
	            		出生日期:{$employee.chushengriqi}
			     	</div>
			     	<div class="field">
	            		身份证号:{$employee.shenfenzhenghao}
			     	</div>
			     	<div class="field">
	            		籍贯:{$employee.jiguan}
			     	</div>
			     	<div class="field">
	            		添加时间:{$employee.addtime}
			     	</div>
			        <a class="btn btn-primary top5" href="{:url('Employee/frontshow',array('bianhao'=>$employee['bianhao']))}">详情</a>
			        <a class="btn btn-primary top5" onclick="employeeEdit('{$employee.bianhao}');" style="display:none;">修改</a>
			        <a class="btn btn-primary top5" onclick="employeeDelete('{$employee.bianhao}');" style="display:none;">删除</a>
			     </div>
			</div>
			{/volist}

			<div class="row">
				<div class="col-md-12">
					<nav class="pull-left">
						<ul class="pagination">
							<li><a href="#" onclick="GoToPage({$currentPage-1},{$totalPage});" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
							<?php
								$startPage = $currentPage - 5;
								$endPage = $currentPage + 5;
								if($startPage < 1) $startPage=1;
								if($endPage > $totalPage) $endPage = $totalPage;
								for($i=$startPage;$i<=$endPage;$i++) {
							?>
							<li class="<?php echo $currentPage==$i?"active":""; ?>"><a href="#"  onclick="GoToPage({$i},{$totalPage});">{$i}</a></li>
							<?php } ?>
							<li><a href="#" onclick="GoToPage({$currentPage+1},{$totalPage});"><span aria-hidden="true">&raquo;</span></a></li>
						</ul>
					</nav>
					<div class="pull-right" style="line-height:75px;" >共有{$recordNumber}条记录，当前第 {$currentPage}/{$totalPage}  页</div>
				</div>
			</div>
		</div>
	</div>

	<div class="col-md-3 wow fadeInRight">
		<div class="page-header">
    		<h1>员工查询</h1>
		</div>
		<form name="employeeQueryForm" id="employeeQueryForm" action="{:url('Employee/frontlist')}" class="mar_t15" method="post">
			<div class="form-group">
				<label for="bianhao">员工编号:</label>
				<input type="text" id="bianhao" name="bianhao" value="{$bianhao}" class="form-control" placeholder="请输入员工编号">
			</div>
			<div class="form-group">
				<label for="xingming">姓名:</label>
				<input type="text" id="xingming" name="xingming" value="{$xingming}" class="form-control" placeholder="请输入姓名">
			</div>
            <div class="form-group">
            	<label for="bumenObj_bumenbianhao">部门：</label>
                <select id="bumenObj_bumenbianhao" name="bumenObj_bumenbianhao" class="form-control">
                	<option value="">不限制</option>
	 				<?php
	 				foreach($bumenList as $bumen) {
	 					$selected = "";
 					if($bumenObj['bumenbianhao'] == $bumen['bumenbianhao'])
 						$selected = "selected";
	 				?>
 				 <option value="{$bumen.bumenbianhao}" {$selected}>{$bumen.bumenmingcheng}</option>
	 				<?php
	 				}
	 				?>
 			</select>
            </div>
			<div class="form-group">
				<label for="danrenzhiwu">担任职务:</label>
				<input type="text" id="danrenzhiwu" name="danrenzhiwu" value="{$danrenzhiwu}" class="form-control" placeholder="请输入担任职务">
			</div>
			<div class="form-group">
				<label for="chushengriqi">出生日期:</label>
				<input type="text" id="chushengriqi" name="chushengriqi" class="form-control"  placeholder="请选择出生日期" value="{$chushengriqi}" onclick="SelectDate(this,'yyyy-MM-dd')" />
			</div>
			<div class="form-group">
				<label for="shenfenzhenghao">身份证号:</label>
				<input type="text" id="shenfenzhenghao" name="shenfenzhenghao" value="{$shenfenzhenghao}" class="form-control" placeholder="请输入身份证号">
			</div>
            <input type=hidden name=currentPage id="currentPage" value="{$currentPage}" />
            <button type="submit" class="btn btn-primary" onclick="$('#currentPage').val(1);return true;">查询</button>
        </form>
	</div>

		</div>
</div>
<div id="employeeEditDialog" class="modal fade" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title"><i class="fa fa-edit"></i>&nbsp;员工信息编辑</h4>
      </div>
      <div class="modal-body" style="height:450px; overflow: scroll;">
      	<form class="form-horizontal" name="employeeEditForm" id="employeeEditForm" enctype="multipart/form-data" method="post"  class="mar_t15">
		  <div class="form-group">
			 <label for="employee_bianhao_edit" class="col-md-3 text-right">员工编号:</label>
			 <div class="col-md-9"> 
			 	<input type="text" id="employee_bianhao_edit" name="employee.bianhao" class="form-control" placeholder="请输入员工编号" readOnly>
			 </div>
		  </div> 
		  <div class="form-group">
		  	 <label for="employee_mima_edit" class="col-md-3 text-right">密码:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_mima_edit" name="employee_mima" class="form-control" placeholder="请输入密码">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_xingming_edit" class="col-md-3 text-right">姓名:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_xingming_edit" name="employee_xingming" class="form-control" placeholder="请输入姓名">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_xingbie_edit" class="col-md-3 text-right">性别:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_xingbie_edit" name="employee_xingbie" class="form-control" placeholder="请输入性别">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_bumenObj_bumenbianhao_edit" class="col-md-3 text-right">部门:</label>
		  	 <div class="col-md-9">
			    <select id="employee_bumenObj_bumenbianhao_edit" name="employee_bumenObj_bumenbianhao" class="form-control">
			    </select>
		  	 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_danrenzhiwu_edit" class="col-md-3 text-right">担任职务:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_danrenzhiwu_edit" name="employee_danrenzhiwu" class="form-control" placeholder="请输入担任职务">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_minzu_edit" class="col-md-3 text-right">民族:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_minzu_edit" name="employee_minzu" class="form-control" placeholder="请输入民族">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_chushengriqi_edit" class="col-md-3 text-right">出生日期:</label>
		  	 <div class="col-md-9">
                <div class="input-group date employee_chushengriqi_edit col-md-12" data-link-field="employee_chushengriqi_edit" data-link-format="yyyy-mm-dd">
                    <input class="form-control" id="employee_chushengriqi_edit" name="employee_chushengriqi" size="16" type="text" value="" placeholder="请选择出生日期" readonly>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                </div>
		  	 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_shenfenzhenghao_edit" class="col-md-3 text-right">身份证号:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_shenfenzhenghao_edit" name="employee_shenfenzhenghao" class="form-control" placeholder="请输入身份证号">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_jiguan_edit" class="col-md-3 text-right">籍贯:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_jiguan_edit" name="employee_jiguan" class="form-control" placeholder="请输入籍贯">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_wenhuachengdu_edit" class="col-md-3 text-right">文化程度:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_wenhuachengdu_edit" name="employee_wenhuachengdu" class="form-control" placeholder="请输入文化程度">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_zhengzhimianmao_edit" class="col-md-3 text-right">政治面貌:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_zhengzhimianmao_edit" name="employee_zhengzhimianmao" class="form-control" placeholder="请输入政治面貌">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_hunyinqingkuang_edit" class="col-md-3 text-right">婚姻状况:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_hunyinqingkuang_edit" name="employee_hunyinqingkuang" class="form-control" placeholder="请输入婚姻状况">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_biyeyuanxiao_edit" class="col-md-3 text-right">毕业院校:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_biyeyuanxiao_edit" name="employee_biyeyuanxiao" class="form-control" placeholder="请输入毕业院校">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_zhuanye_edit" class="col-md-3 text-right">专业:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_zhuanye_edit" name="employee_zhuanye" class="form-control" placeholder="请输入专业">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_biyeshijian_edit" class="col-md-3 text-right">毕业时间:</label>
		  	 <div class="col-md-9">
                <div class="input-group date employee_biyeshijian_edit col-md-12" data-link-field="employee_biyeshijian_edit" data-link-format="yyyy-mm-dd">
                    <input class="form-control" id="employee_biyeshijian_edit" name="employee_biyeshijian" size="16" type="text" value="" placeholder="请选择毕业时间" readonly>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                </div>
		  	 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_shoujihao_edit" class="col-md-3 text-right">手机号:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_shoujihao_edit" name="employee_shoujihao" class="form-control" placeholder="请输入手机号">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_jibengongzi_edit" class="col-md-3 text-right">基本工资:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_jibengongzi_edit" name="employee_jibengongzi" class="form-control" placeholder="请输入基本工资">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_xianzhuzhi_edit" class="col-md-3 text-right">现住址:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="employee_xianzhuzhi_edit" name="employee_xianzhuzhi" class="form-control" placeholder="请输入现住址">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_zhaopian_edit" class="col-md-3 text-right">照片:</label>
		  	 <div class="col-md-9">
			    <img  class="img-responsive" id="employee_zhaopianImg" border="0px"/><br/>
			    <input type="hidden" id="employee_zhaopian_edit" name="employee_zhaopian"/>
			    <input id="zhaopianFile" name="zhaopianFile" type="file" size="50" />
		  	 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_beizhu_edit" class="col-md-3 text-right">备注:</label>
		  	 <div class="col-md-9">
			    <textarea id="employee_beizhu_edit" name="employee_beizhu" rows="8" class="form-control" placeholder="请输入备注"></textarea>
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="employee_addtime_edit" class="col-md-3 text-right">添加时间:</label>
		  	 <div class="col-md-9">
                <div class="input-group date employee_addtime_edit col-md-12" data-link-field="employee_addtime_edit">
                    <input class="form-control" id="employee_addtime_edit" name="employee_addtime" size="16" type="text" value="" placeholder="请选择添加时间" readonly>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                </div>
		  	 </div>
		  </div>
		</form> 
	    <style>#employeeEditForm .form-group {margin-bottom:5px;}  </style>
      </div>
      <div class="modal-footer"> 
      	<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      	<button type="button" class="btn btn-primary" onclick="ajaxEmployeeModify();">提交</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
{include file="common/footer" /}
<script src="__PUBLIC__/plugins/jquery.min.js"></script>
<script src="__PUBLIC__/plugins/bootstrap.js"></script>
<script src="__PUBLIC__/plugins/wow.min.js"></script>
<script src="__PUBLIC__/plugins/bootstrap-datetimepicker.min.js"></script>
<script src="__PUBLIC__/plugins/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/jsdate.js"></script>
<script>
/*跳转到查询结果的某页*/
function GoToPage(currentPage,totalPage) {
    if(currentPage==0) return;
    if(currentPage>totalPage) return;
    document.employeeQueryForm.currentPage.value = currentPage;
    document.employeeQueryForm.submit();
}

/*可以直接跳转到某页*/
function changepage(totalPage)
{
    var pageValue=document.employeeQueryForm.pageValue.value;
    if(pageValue>totalPage) {
        alert('你输入的页码超出了总页数!');
        return ;
    }
    document.employeeQueryForm.currentPage.value = pageValue;
    documentemployeeQueryForm.submit();
}

/*弹出修改员工界面并初始化数据*/
function employeeEdit(bianhao) {
	$.ajax({
		url :  "{:url('Employee/update')}?bianhao=" + bianhao ,
		type : "get",
		dataType: "json",
		success : function (employee, response, status) {
			if (employee) {
				$("#employee_bianhao_edit").val(employee.bianhao);
				$("#employee_mima_edit").val(employee.mima);
				$("#employee_xingming_edit").val(employee.xingming);
				$("#employee_xingbie_edit").val(employee.xingbie);
				$.ajax({
					url: "{:url('Bumen/listAll')}",
					type: "get",
					dataType: "json",
					success: function(bumens,response,status) { 
						$("#employee_bumenObj_bumenbianhao_edit").empty();
						var html="";
		        		$(bumens).each(function(i,bumen){
		        			html += "<option value='" + bumen.bumenbianhao + "'>" + bumen.bumenmingcheng + "</option>";
		        		});
		        		$("#employee_bumenObj_bumenbianhao_edit").html(html);
		        		$("#employee_bumenObj_bumenbianhao_edit").val(employee.bumenObj);
					}
				});
				$("#employee_danrenzhiwu_edit").val(employee.danrenzhiwu);
				$("#employee_minzu_edit").val(employee.minzu);
				$("#employee_chushengriqi_edit").val(employee.chushengriqi);
				$("#employee_shenfenzhenghao_edit").val(employee.shenfenzhenghao);
				$("#employee_jiguan_edit").val(employee.jiguan);
				$("#employee_wenhuachengdu_edit").val(employee.wenhuachengdu);
				$("#employee_zhengzhimianmao_edit").val(employee.zhengzhimianmao);
				$("#employee_hunyinqingkuang_edit").val(employee.hunyinqingkuang);
				$("#employee_biyeyuanxiao_edit").val(employee.biyeyuanxiao);
				$("#employee_zhuanye_edit").val(employee.zhuanye);
				$("#employee_biyeshijian_edit").val(employee.biyeshijian);
				$("#employee_shoujihao_edit").val(employee.shoujihao);
				$("#employee_jibengongzi_edit").val(employee.jibengongzi);
				$("#employee_xianzhuzhi_edit").val(employee.xianzhuzhi);
				$("#employee_zhaopian_edit").val(employee.zhaopian);
				$("#employee_zhaopianImg").attr("src", "__PUBLIC__/" + employee.zhaopian);
				$("#employee_beizhu_edit").val(employee.beizhu);
				$("#employee_addtime_edit").val(employee.addtime);
				$('#employeeEditDialog').modal('show');
			} else {
				alert("获取信息失败！");
			}
		}
	});
}

/*删除员工信息*/
function employeeDelete(bianhao) {
	if(confirm("确认删除这个记录")) {
		$.ajax({
			type : "POST",
			url: "{:url('Employee/deletes')}",
			data : {
				bianhaos : bianhao,
			},
			dataType: "json",
			success : function (obj) {
				if (obj.success) {
					alert("删除成功");
					$("#employeeQueryForm").submit();
					//location.href= "{:url('Employee/frontlist')}";
				}
				else 
					alert(obj.message);
			},
		});
	}
}

/*ajax方式提交员工信息表单给服务器端修改*/
function ajaxEmployeeModify() {
	$.ajax({
		url :  "{:url('Employee/update')}",
		type : "post",
		dataType: "json",
		data: new FormData($("#employeeEditForm")[0]),
		success : function (obj, response, status) {
            if(obj.success){
                alert("信息修改成功！");
                $("#employeeQueryForm").submit();
            }else{
                alert(obj.message);
            } 
		},
		processData: false,
		contentType: false,
	});
}

$(function(){
	/*小屏幕导航点击关闭菜单*/
    $('.navbar-collapse a').click(function(){
        $('.navbar-collapse').collapse('hide');
    });
    new WOW().init();

    /*出生日期组件*/
    $('.employee_chushengriqi_edit').datetimepicker({
    	language:  'zh-CN',  //语言
    	format: 'yyyy-mm-dd',
    	minView: 2,
    	weekStart: 1,
    	todayBtn:  1,
    	autoclose: 1,
    	minuteStep: 1,
    	todayHighlight: 1,
    	startView: 2,
    	forceParse: 0
    });
    /*毕业时间组件*/
    $('.employee_biyeshijian_edit').datetimepicker({
    	language:  'zh-CN',  //语言
    	format: 'yyyy-mm-dd',
    	minView: 2,
    	weekStart: 1,
    	todayBtn:  1,
    	autoclose: 1,
    	minuteStep: 1,
    	todayHighlight: 1,
    	startView: 2,
    	forceParse: 0
    });
    /*添加时间组件*/
    $('.employee_addtime_edit').datetimepicker({
    	language:  'zh-CN',  //语言
    	format: 'yyyy-mm-dd hh:ii:ss',
    	weekStart: 1,
    	todayBtn:  1,
    	autoclose: 1,
    	minuteStep: 1,
    	todayHighlight: 1,
    	startView: 2,
    	forceParse: 0
    });
})
</script>
</body>
</html>

